import { observable, action } from 'mobx'

class QuorumNetwork {
    @observable networkList = [];

    @action getNetworkList() {
      return this.networkList
    }
    @action setNetworkList(value) {
      this.networkList.push(value)
    }
    @action setNetworkStatus(key, status) {
      this.networkList.map(item => {
        if (key = item.key) {
          item.status = status
        }
        return item
      })
    }
    @action getNetworkInfo(key) {
      let arr = this.networkList.filter(item => item.key == key)
      let obj = arr.length && arr[0] || {}
      return obj
    }
    @action deleteNetwork(key) {
      let arr = this.networkList.filter(item => item.key != key)
      this.networkList = arr
    }
}

export default new QuorumNetwork()
